package com.yourname.lab4.v2;

public class ExerciseSystem {
    public static void main(String[] args) {
        Exercise exercise = new Exercise();

        System.out.println("生成50道加法题：");
        exercise.generateAddition(50);
        exercise.displayFormatted();

        exercise = new Exercise(); // 重置
        System.out.println("\n生成50道减法题：");
        exercise.generateSubtraction(50);
        exercise.displayFormatted();

        exercise = new Exercise(); // 重置
        System.out.println("\n生成50道混合题：");
        exercise.generateMixed(50);
        exercise.displayFormatted();

        // 验证题目数量
        System.out.println("加法题数量: " + countByType(exercise, AdditionExpression.class));
        System.out.println("减法题数量: " + countByType(exercise, SubtractionExpression.class));
    }

    private static int countByType(Exercise exercise, Class<?> type) {
        int count = 0;
        for (AbstractExpression exp : exercise.getExpressions()) {
            if (type.isInstance(exp)) {
                count++;
            }
        }
        return count;
    }
}
